<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            .d1{
                width: 5rem;
                height: 5rem;
                font-size: 1rem;
                text-align: center;
                background-color:skyblue;
            }
        </style>
    </head>
    <body>
        <div class="d1">helloworld</div>
        <script type="text/javascript">
            
            window.onresize = function(){
                setRem();
            };

           var setRem = function(){
                var screenWidth = window.innerWidth;
                var danwei = screenWidth/4.5;
                var html = document.querySelector("html");
                html.style.fontSize = danwei + "px";

           }
           setRem();




        </script>
    </body>
</html>